In [1]:
# loading python modules
import numpy as np
np.random.seed(0)
%matplotlib inline
from __future__ import division
In [2]:
# loading custom inet modules
from inet import DataLoader, __version__
from inet.motifs import iiconcounter
from inet.utils import II_slice
print('Inet version {}'.format(__version__))
In [3]:
# use the dataset to create the null hypothesis
mydataset = DataLoader('../data/PV')
In [4]:
# for the moment, we only count experiments with 3 PVs
# later we use mydataset.PV[2:]|
PV3 = sum(mydataset.IN[3].values())
PV3
Out[4]:
In [5]:
# select experiments with only 3 PVs
pvlist = list()
for i in range(len(mydataset)):
if '3_1' in mydataset.experiment[i]['fname']:
pvlist.append(i)
print('{:3d} --> {}'.format(i, mydataset.experiment[i]['fname']))
In [6]:
#check that experiment
II_slice(mydataset.experiment[56]['matrix'],3)
Out[6]:
In [7]:
matrix = II_slice(mydataset.experiment[56]['matrix'],3)
matrix
Out[7]:
In [8]:
mymatrix = matrix.copy()
mymatrix[mymatrix==2]=0
mymatrix
Out[8]:
In [9]:
iiconcounter(matrix)
Out[9]:
In [12]:
np.nonzero(mymatrix)
Out[12]:
In [24]:
pre, post = np.nonzero(mymatrix)
np.unique(post, return_index=1, return_counts=1)
Out[24]:
In [10]:
# count number of total convergent motifs
mydataset.motif['ii_con']
Out[10]:
In [11]:
# select recording of the only convergent motifs
for i in pvlist:
if mydataset.experiment[i]['motif']['ii_con'] ['found']:
print(i)
In [12]:
# count number of total convergent motifs
mydataset.motif['ii_div']
Out[12]:
In [13]:
# select recording of the only convergent motifs
for i in pvlist:
if mydataset.experiment[i]['motif']['ii_div']['found']:
print(i)
In [14]:
# count number of total convergent motifs++
mydataset.motif['ii_lin']
Out[14]:
In [15]:
# select recording of the only convergent motifs
for i in pvlist:
if mydataset.experiment[i]['motif']['ii_lin']['found']:
print(i)
In [16]:
matrix = II_slice(mydataset.experiment[56]['matrix'],3)
In [17]:
matrix[1,1]=2
In [18]:
for i in range(3):
print(matrix[:,i])
In [19]:
np.nonzero(matrix[:,0])
Out[19]:
In [38]:
from itertools import permutations
In [79]:
permutations?
In [82]:
for i,j in permutations(np.array([1,2,3]), 2):
print(i,j)
In [86]:
permutations(3, 2)
In [77]:
matrix
Out[77]:
In [ ]: